package com.example.materialviewpagerdemo.view;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.materialviewpagerdemo.R;
import com.example.materialviewpagerdemo.bean.LeftListModel;

import java.util.List;

public class LeftListAdapter extends BaseAdapter{
    Context context;
    List<LeftListModel> leftListModels;

    public LeftListAdapter(Context context, List<LeftListModel> leftListModels) {
        this.context = context;
        this.leftListModels = leftListModels;
    }

    @Override
    public int getCount() {
        return leftListModels.size();
    }

    @Override
    public Object getItem(int position) {
        return leftListModels.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        @SuppressLint("ViewHolder") View view=View.inflate(context, R.layout.leftlist_item,null);
        ImageView imageView=view.findViewById(R.id.img_item);
        TextView textView=view.findViewById(R.id.text_item);
        imageView.setImageResource(leftListModels.get(position).getImgId());
        textView.setText(leftListModels.get(position).getItemContent());
        return view;
    }
}
